Skip to content

Deleting a user modal won't close and page won't redirect #6560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smithellis
Copy link
Contributor

When users attempted to delete their account, the form would submit but the modal would only shrink and empty instead of properly redirecting to the /users/close_account URL. This was caused by an interaction between the modal system(s) and the form submission process.

This fix:

  • Handles the delete button click event directly
  • Ensures both modal systems (Mzp.Modal and $.kbox) are properly closed
  • Adds a small delay before programmatically submitting the form to allow modal closing to complete
  • Prevents the default button submission behavior to take control of the submission flow

When users attempted to delete their account, the form would submit but the modal would only shrink and empty instead of properly redirecting to the /users/close_account URL. This was caused by an interaction between the modal system(s) and the form submission process.

This fix:
- Handles the delete button click event directly
- Ensures both modal systems (Mzp.Modal and $.kbox) are properly closed
- Adds a small delay before programmatically submitting the form to allow modal closing to complete
- Prevents the default button submission behavior to take control of the submission flow
@akatsoulas akatsoulas requested a review from Copilot March 17, 2025 18:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the account deletion modal does not close properly and fails to redirect the page upon account deletion.

  • Adds a dedicated click event handler for the delete account button
  • Closes both modal systems (Mzp.Modal and $.kbox) before form submission
  • Delays the form submission to allow modal closing to complete

Mzp.Modal.closeModal();
}

if ($.kbox) {
Copy link
Preview

Copilot AI Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider verifying the existence of $.kbox using a typeof check (e.g. typeof $.kbox !== 'undefined') for consistency with the check for Mzp.Modal to avoid potential run-time errors.

Suggested change
if ($.kbox) {
if (typeof $.kbox !== 'undefined') {

Copilot uses AI. Check for mistakes.


// Directly submit the form after a small delay
// This ensures the modal closing completes before submission
setTimeout(function() {
Copy link
Preview

Copilot AI Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a hardcoded delay of 50ms might be brittle if modal closing is slower than expected. Consider implementing a callback from the modal closing process or extracting the delay into a clearly named constant for easier adjustments.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants